home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 January: Mac OS SDK / Dev.CD Jan 98 SDK1.toast / Development Kits (Disc 1) / Open Transport / Sample Code / DTS Sample Code / Option Management Samples / EnableRawModeSample.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-11-19  |  1.5 KB  |  55 lines  |  [TEXT/MMCC]

  1. #include <OpenTransport.h>            // open transport files            
  2. #include <OpenTptLinks.h>
  3.  
  4. OSStatus DoNegotiateRawModeOption(EndpointRef ep, UInt32 rawModeOption);
  5.  
  6. // important note - use the options as defined in the OpenTptLinks.h header
  7. // when setting the rawModeOption parameter.
  8. OSStatus DoNegotiateRawModeOption(EndpointRef ep, UInt32 rawModeOption)
  9.  
  10. {
  11.     UInt8        buf[kOTFourByteOptionSize];    // define buffer for fourByte Option size
  12.     TOption*    opt;                        // option ptr to make items easier to access
  13.     TOptMgmt    req;
  14.     TOptMgmt    ret;
  15.     OSStatus    err;
  16.     Boolean        isAsync = false;
  17.     
  18.     opt = (TOption*)buf;                    // set option ptr to buffer
  19.     req.opt.buf    = buf;
  20.     req.opt.len    = sizeof(buf);
  21.     req.flags    = T_NEGOTIATE;                // negotiate for rawmode option
  22.  
  23.     ret.opt.buf = buf;
  24.     ret.opt.maxlen = kOTFourByteOptionSize;
  25.     
  26.  
  27.     opt->level    = LNK_TPI;                    // dealing with tpi
  28.     opt->name    = OPT_SETRAWMODE;
  29.     opt->len    = kOTFourByteOptionSize;
  30.     opt->status = 0;
  31.     *(UInt32*)opt->value = rawModeOption;        // set the desired option level, true or false
  32.  
  33.     if (OTIsSynchronous(ep) == false)            // check whether ep sync or not
  34.     {
  35.         isAsync = true;                        // set flag if async
  36.         OTSetSynchronous(ep);                    // set endpoint to sync    
  37.     }
  38.                 
  39.     err = OTOptionManagement(ep, &req, &ret);
  40.     
  41.     if (isAsync == true)                    // restore ep state if necessary
  42.         OTSetAsynchronous(ep);
  43.     
  44.         // if no error then return the option status value
  45.     if (err == kOTNoError)
  46.     {
  47.         if (opt->status != T_SUCCESS)
  48.             err = opt->status;
  49.         else
  50.             err = kOTNoError;
  51.     }
  52.         
  53.     return err;
  54. }
  55.